package com.anolesoft.amljmes.fortysix.controller;

import com.anolesoft.amljmes.fortysix.dto.MesBzzPtdmxDto;
import com.anolesoft.amljmes.fortysix.service.info.MesBzzCpptmxService;
import com.anolesoft.common.core.constant.HttpStatus;
import com.anolesoft.common.core.domain.LoginUser;
import com.anolesoft.common.core.web.domain.AjaxResult;
import com.anolesoft.common.security.util.SecurityUtils;
import com.anolesoft.yr.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping(value="/mesbzzcpptmx")
public class MesBzzCpptmxController {
    @Autowired
    MesBzzCpptmxService mesBzzCpptmxService;

    //根据配套单主键查询
    @PostMapping(value="/queryMatchingDocPk",produces= MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult queryMesBzzCpptmx(@RequestBody Map<String,String> map) {
        String matchingDocPk = map.get("objuid");
        System.out.println("matchingDocPk"+matchingDocPk);
        List<MesBzzPtdmxDto> list=mesBzzCpptmxService.queryMesBzzCpptmx(matchingDocPk);
        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,list);
    }

    // 点击配套修改配套和需求数量
    @PostMapping(value="/updatePt", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult updateCpptmxPt(@RequestBody Map<String,String> map){
        System.out.println(">>>>>>updatePt#############" + map);
        String objuid = map.get("objuid");
        int num = Integer.parseInt(map.get("num"));
        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,mesBzzCpptmxService.updateCpptmxPt(objuid,num));
    }
    // 点击解除修改配套和需求数量
    @PostMapping(value="/updateJc", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult updateCpptmxJc(@RequestBody Map<String,String> map){
        System.out.println(">>>>>>updateJc");
        String objuid = map.get("objuid");
        int num1 = Integer.parseInt(map.get("num1"));
        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,mesBzzCpptmxService.updateCpptmxJc(objuid,num1));
    }
}
